﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WuDada.Core.Member;
using WuDada.Core.Member.Service;

public partial class admin_UC07_0701 : System.Web.UI.Page
{
    private MemberFactory m_MemberFactory;
    private IMemberService m_MemberService;

    protected void Page_Load(object sender, EventArgs e)
    {
        m_MemberFactory = new MemberFactory();
        m_MemberService = m_MemberFactory.GetMemberService();

        if (!Page.IsPostBack)
        {
            fillGridView();
        }
    }

    protected void btnQuery_Click(object sender, ImageClickEventArgs e)
    {
        fillGridView();
    }

    private void fillGridView()
    {
        //搜尋條件
        IDictionary<string, string> conditions = new Dictionary<string, string>();
        DateTime? startDate = ConvertUtil.ToDateTimeMin(txtDateFrom.Text);
        DateTime? endDate = ConvertUtil.ToDateTimeMax(txtDateTo.Text);
        conditions.Add("CreateDateFrom", startDate.ToString());
        conditions.Add("CreateDateTo", endDate.ToString());
        conditions.Add("KeyWord", txtKeyWord.Text.Trim().ToString());

        //分頁
        AspNetPager1.RecordCount = m_MemberService.GetMemberCount(conditions);
        int pageIndex = (AspNetPager1.CurrentPageIndex - 1);
        int pageSize = AspNetPager1.PageSize;

        conditions.Add("PageIndex", pageIndex.ToString());
        conditions.Add("PageSize", pageSize.ToString());

        gvDetail.DataSource = m_MemberService.GetMemberList(conditions);
        gvDetail.DataBind();
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        fillGridView();
    }


    protected void gvDetail_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        //e.Row.Attributes.Add("onmouseover", "javascript:__doPostBack('ctl00$ContentPlaceHolder1$gvDetail','Select$" + e.Row.RowIndex + "')");

    }
}